package com.lagou.controller;

import com.lagou.service.CodeService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author : liuchangling
 * @Descrition :
 * @Date： Created in 5:56 下午 2022/1/31
 */
@RestController
@RequestMapping("/code")
public class CodeController {
    @Reference
    private CodeService codeService;

    /**
     * 生成验证码
     * @param email
     * @return
     */
    @GetMapping("/create/{email}")
    public Boolean create(@PathVariable("email") String email){
        return codeService.createCode(email);
    }

    @GetMapping("/validate/{email}/{code}")
    public Integer validate(@PathVariable("email") String email,@PathVariable("code") String code){
        return codeService.validateCode(email,code);
    }
}
